<html>
<head><meta charset="utf-8"><title>GenericParam as HIR owner · t-compiler · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/index.html">t-compiler</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/GenericParam.20as.20HIR.20owner.html">GenericParam as HIR owner</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="231549562"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/GenericParam%20as%20HIR%20owner/near/231549562" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cjgillot <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/GenericParam.20as.20HIR.20owner.html#231549562">(Mar 23 2021 at 21:50)</a>:</h4>
<p><span class="user-mention" data-user-id="216206">@lcnr</span>, I am rereading <a href="https://github.com/rust-lang/rust/issues/77546">#77546</a>. I am wondering why we need GenericParams to be HIR owners. Removing this special case does not trip on the associated tests. Do you have pointers?</p>



<a name="231550374"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/GenericParam%20as%20HIR%20owner/near/231550374" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/GenericParam.20as.20HIR.20owner.html#231550374">(Mar 23 2021 at 21:57)</a>:</h4>
<p>that's interesting, can't remember why it was needed here</p>



<a name="231550468"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/GenericParam%20as%20HIR%20owner/near/231550468" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/GenericParam.20as.20HIR.20owner.html#231550468">(Mar 23 2021 at 21:58)</a>:</h4>
<p>depending on the <code>ImplTraitContext</code> we already used an hir owner in one of the cases</p>



<a name="231550478"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/GenericParam%20as%20HIR%20owner/near/231550478" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/GenericParam.20as.20HIR.20owner.html#231550478">(Mar 23 2021 at 21:58)</a>:</h4>
<p>so it was inconsistent before that PR which caused the ICE</p>



<a name="231550594"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/GenericParam%20as%20HIR%20owner/near/231550594" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/GenericParam.20as.20HIR.20owner.html#231550594">(Mar 23 2021 at 21:59)</a>:</h4>
<p>if you are able to remove that special case, go ahead and do so  <span aria-label="thumbs up" class="emoji emoji-1f44d" role="img" title="thumbs up">:thumbs_up:</span></p>



<a name="231559837"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/GenericParam%20as%20HIR%20owner/near/231559837" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/GenericParam.20as.20HIR.20owner.html#231559837">(Mar 23 2021 at 23:31)</a>:</h4>
<p>Hmm, if const parameter has a default (not yet implemented) which is a constant expression, will it need the parameter to be a HIR owner?</p>



<a name="231560532"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/GenericParam%20as%20HIR%20owner/near/231560532" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/GenericParam.20as.20HIR.20owner.html#231560532">(Mar 23 2021 at 23:39)</a>:</h4>
<p>What is the point of HIR owners actually?<br>
Being starting points for HirId's? But that's DefIds/DefPath's that we are building in resolve, which seems a different thing.<br>
Owning bodies? (E.g. pieces of executable code, including constant expressions.) Then why do you need anything besides functions and <code>AnonConst</code>s for that?</p>



<a name="231560667"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/GenericParam%20as%20HIR%20owner/near/231560667" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/GenericParam.20as.20HIR.20owner.html#231560667">(Mar 23 2021 at 23:41)</a>:</h4>
<p>And how is it related to queries/incremental (because I've seen that it is related from casually looking through cjgillot's PRs).</p>



<a name="231624907"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/GenericParam%20as%20HIR%20owner/near/231624907" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cjgillot <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/GenericParam.20as.20HIR.20owner.html#231624907">(Mar 24 2021 at 12:32)</a>:</h4>
<p>HIR owners are a way to organise the HIR. They are a subset of all DefIds. The subtlety used to be largely ad-hoc.<br>
IIUC, the new definition is that a HIR owner can be typechecked completely and independently from others. This motivates that closures (for instance) are not HIR owners. Likewise, GenericParams may depend on one another for typechecking, so will need to be in the same HIR owner.</p>



<a name="231648409"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/GenericParam%20as%20HIR%20owner/near/231648409" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/GenericParam.20as.20HIR.20owner.html#231648409">(Mar 24 2021 at 14:59)</a>:</h4>
<blockquote>
<p>Likewise, GenericParams may depend on one another for typechecking, so will need to be in the same HIR owner.</p>
</blockquote>
<p>they are currently not able to, and i assume that they will never be</p>



<a name="231648446"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/GenericParam%20as%20HIR%20owner/near/231648446" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/GenericParam.20as.20HIR.20owner.html#231648446">(Mar 24 2021 at 14:59)</a>:</h4>
<p>also, defaults are now implement: <a href="https://github.com/rust-lang/rust/issues/75384">#75384</a></p>



<a name="231648911"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/GenericParam%20as%20HIR%20owner/near/231648911" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/GenericParam.20as.20HIR.20owner.html#231648911">(Mar 24 2021 at 15:01)</a>:</h4>
<blockquote>
<p>will it need the parameter to be a HIR owner</p>
</blockquote>
<p>it needs the parameter to be a parent in the hir tree, but it's not an owner afaik</p>



<a name="231650397"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/GenericParam%20as%20HIR%20owner/near/231650397" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/GenericParam.20as.20HIR.20owner.html#231650397">(Mar 24 2021 at 15:09)</a>:</h4>
<blockquote>
<p>IIUC, the new definition is that a HIR owner can be typechecked completely and independently from others. </p>
</blockquote>
<p>is this intended to be a requirement for something to be a HIR owner or the exact definition</p>



<a name="231650495"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/GenericParam%20as%20HIR%20owner/near/231650495" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/GenericParam.20as.20HIR.20owner.html#231650495">(Mar 24 2021 at 15:10)</a>:</h4>
<p>so if there is something that can be typechecked separately, should we make it a hir owner even if it isn't strictly needed?</p>



<a name="231664794"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/GenericParam%20as%20HIR%20owner/near/231664794" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cjgillot <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/GenericParam.20as.20HIR.20owner.html#231664794">(Mar 24 2021 at 16:28)</a>:</h4>
<p>I don't know a precise definition. The best definition I have is "HIR owners are the granularity of typeck queries". If something can be typechecked independently from the surrounding code, it should be made a HIR owner.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>